﻿@page "/tables/dynamic"

<h3>@DynamicLocalizer["Title"]</h3>

<h4>@DynamicLocalizer["Desc"]</h4>

<DemoBlock Title="@DynamicLocalizer["DataTableTitle"]" Introduction="@DynamicLocalizer["DataTableIntro"]" Name="DataTable">
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" />
</DemoBlock>

<DemoBlock Title="@DynamicLocalizer["EditTitle"]" Introduction="@DynamicLocalizer["EditIntro"]" Name="Edit">
    <p>@((MarkupString)DynamicLocalizer["EditP"].Value)</p>
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" ModelEqualityComparer="ModelEqualityComparer"
           IsMultipleSelect="true" IsBordered="true" IsStriped="true" @bind-SelectedRows="SelectedItems"
           ShowToolbar="true" ShowExtendButtons="true" />
    <div class="mt-3">
        @foreach(var item in SelectedItems)
        {
            <div>@item.GetValue(nameof(Foo.Name))</div>
        }
    </div>
</DemoBlock>

<DemoBlock Title="@DynamicLocalizer["DynamicColTitle"]" Introduction="@DynamicLocalizer["DynamicColIntro"]" Name="DynamicCol">
    <Table TItem="DynamicObject" DynamicContext="DataTableDynamicContext" ModelEqualityComparer="ModelEqualityComparer"
           IsMultipleSelect="true" IsBordered="true" IsStriped="true"
           ShowToolbar="true" ShowExtendButtons="true">
        <TableToolbarTemplate>
            <TableToolbarButton TItem="DynamicObject" Color="Color.Info" Icon="fa fa-fw fa-plus-circle" Text="@ButtonAddColumnText" OnClick="OnAddColumn" />
            <TableToolbarButton TItem="DynamicObject" Color="Color.Secondary" Icon="fa fa-fw fa-minus-circle" Text="@ButtonRemoveColumnText" OnClick="OnRemoveColumn" />
        </TableToolbarTemplate>
    </Table>
</DemoBlock>

<DemoBlock Title="@DynamicLocalizer["DataTablePageTitle"]" Introduction="@DynamicLocalizer["DataTablePageIntro"]" Name="Page">
    <Table TItem="DynamicObject" DynamicContext="DataTablePageDynamicContext" />
    <Pagination PageItemsSource="@PageItemsSource" PageItems="@PageItems" TotalCount="@TotalCount" PageIndex="@PageIndex" OnPageClick="@OnPageClick" OnPageItemsChanged="@OnPageItemsChanged" class="mt-3"></Pagination>
</DemoBlock>

